package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Order;
import com.example.demo.entity.Order2;
import com.example.demo.entity.Commdity;
import com.example.demo.entity.Shop;
import com.example.demo.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface OrdersMapper extends BaseMapper<Order2> {

    //获取订单中的所有商品信息
    @Select("SELECT commdity.id,order2.numid,order2.commodityid,commdity.name,commdity.description," +
            "commdity.price,commdity.shopid,commdity.classification,order2.relaid,order2.state,order2.number " +
            "from order2,commdity where order2.commodityid=commdity.id ")
    List<Order2> findall();

    //根据所属的订单编号查找对应商品
    @Select("SELECT commdity.id,order2.numid,order2.commodityid,commdity.name,commdity.description," +
            "commdity.price,commdity.shopid,commdity.classification,order2.relaid,order2.state,order2.number " +
            "from order2,commdity where order2.commodityid=commdity.id and order2.relaid=#{relaid} ")
    List<Order2> findgoods_Byrelaid(int relaid);

    //商品申请退单
    @Select("UPDATE order2 SET order2.state=-1 where order2.numid=#{numid}")
    Boolean modify1(int numid);

    @Select("SELECT numid FROM order2 WHERE order2.relaid=#{relaid} and order2.state=0")
    List<Order2> panduanorder(int relaid);

    @Select("UPDATE order2 SET order2.state=-1 where order2.numid=#{numid} and order2.relaid=#{relaid}")
    List<Order2> modify11(int numid,int relaid);

    //取消订单商品
    @Select("UPDATE order2 SET order2.state=-1 where order2.numid=#{numid} and order2.relaid=#{relaid}")
    List<Order2> modify12(int numid,int relaid);

    //确认发货
    @Select("UPDATE order2 SET order2.state=3 where order2.numid=#{numid} and order2.relaid=#{relaid}")
    List<Order2> modify13(int numid,int relaid);

    //退单
    @Select("UPDATE order2 SET order2.state=-3 where order2.numid=#{numid} and order2.relaid=#{relaid}")
    List<Order2> modify14(int numid,int relaid);

}
